<?php


namespace App\Helpers;


use Illuminate\Http\Request;
use Illuminate\Support\Collection;

class Helpers
{

    /**
     * @param Collection $collect
     * @param $column
     * @return array
     * @author thanatos thanatos915@163.com
     */
    public static function getModelSelect($collect, $column)
    {
        $data = [];
        foreach ($collect as $item) {
            $value = $item->$column ?: $item->id;
            $data[$item->id] = $value;
        }
        return $data;
    }

    public static function getFileUrl($url)
    {
        return '/uploads/' . $url;
    }

    public static function getUserId()
    {
        /** @var Request $request */
        $request = request();

        $sessionId = $request->session()->getId();
        return $sessionId;
    }


}
